var currentShown = null;

function showSettings(id)
{
	// If an existing author currently has it's settings being shown it must be hidden
	if (currentShown != null)
	{
		// Hide settings for the existing element
		hideSettings(currentShown);
	}
	
	// Show the settings for the seleted element
	document.getElementById("Author_" + id + "_Actions").className = "";
	
	// Set the currently shown settings id
	currentShown = id;
}

function hideSettings(id)
{
	// Hide the settings
	document.getElementById("Author_" + id + "_Actions").className = "hide";
}

function removeAuthor(id, authorName)
{
	// Confirm that the user actually wants to remove the element
	if (confirm("Are you sure you want to remove \"" + authorName + "\"?"))
	{
		// Create the AJAX Object
		xmlHttp = getXmlHttpObject();
		
		// Create the function
		xmlHttp.onreadystatechange = function()
		{
			if (xmlHttp.readyState == 4)
			{
				//	Get the element to remove
				var el = document.getElementById("Author_" + id);

				// Remove the author's element
				el.parentNode.removeChild(el);

				// Reset the currently selected element to nothing
				currentShown = null;
				
				alert(xmlHttp.responseText);
			}
		}	
		
		xmlHttp.open("GET", "author_script.php?type=author&action=remove&id=" + id, true);
		xmlHttp.send(null);
	}
}